<template>
  <div class="login-page">
    <van-nav-bar title="账号登录" left-arrow />
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="username"
        placeholder="请输入账号"
        :rules="[
          { required: true, message: '请填写用户名' },
          { pattern: /^\w{5,}$/, message: '用户名至少包含5个字符' },
        ]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password "
        placeholder="请输入密码"
        :rules="[
          { required: true, message: '请填写密码' },
          { pattern: /^\w{6,}$/, message: '密码至少包含6个字符' },
        ]"
      />
      <div style="margin: 16px">
        <van-button block type="info" native-type="submit">登录</van-button>

        <router-link to="/register" class="link"
          >还没有账号,去注册~</router-link
        >
      </div>
    </van-form>
  </div>
</template>

<script>
export default {
  name: "login-page",
  data() {
    return {
      username: "hhhhh",
      password: "123456",
    };
  },
  methods: {
    onSubmit(values) {
      console.log("submit", values);
    },
  },
};
</script>

<style lang="less" scoped>
//跳向注册
.link {
  display: block;
  margin-top: 30px;
  color: #666;
  font-size: 14px;
}

//输入框
/deep/ .van-field__control {
  height: 60px;
  width: 100%;
  padding: 2px 0px;
  border: 0px;
  color: rgb(0, 0, 0);
  font-size: 17px;
  background-color: transparent;
}
.login-page {
  text-align: center;
}

//顶部栏
/deep/ .van-nav-bar {
  background-color: #21b97a;
  margin-bottom: 10px;
  .van-icon {
    color: white;
  }
}

//顶部文字
/deep/ .van-nav-bar__title {
  color: white;
  font-size: 18px;
}

/deep/ .van-cell {
  padding: 2px 16px;
}

//按钮
/deep/ .van-button {
  height: 50px;
  font-size: 18px;
}
</style>
